const app = getApp()
import Toast from '@vant/weapp/toast/toast'
import Dialog from '@vant/weapp/dialog/dialog';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sign: null,
    customCalloutobj: {},
    CodingValue:'',
    FirmValue:'',
    CjstateValue: '',
    CjstateIndex:0,
    YxstateValue: '',
    YxstateIndex:0,
    TsstateValue: '',
    TsstateIndex:0,
    ispopupShow: false,
    pickerTitle: '',
    columnsCjState:[{
      id: 0,
      text: '按层级搜索'
    }, {
      id: 1,
      text: '选项一'
    }, {
      id: 2,
      text: '选项二'
    }],
    columnsYxState:[{
      id: 0,
      text: '按状态搜索'
    }, {
      id: 1,
      text: '运行中'
    }, {
      id: 2,
      text: '停止中'
    }],
    columnsTsState: [{
      id: 0,
      text: '按状态搜索'
    }, {
      id: 1,
      text: '是'
    }, {
      id: 2,
      text: '否'
    }],
    customStyleSelect: "padding:0 0 0 20rpx;height: 100%;width:100%;color:#808285;"
  },
  //设备编码
  onCodingChange(e){
    let that = this
    that.setData({
      CodingValue:e.detail
    })
  },
  //公司名称
  onFirmChange(e){
    let that = this
    that.setData({
      FirmValue:e.detail
    })
  },
  //层级
  onConfirmCjState(event) {
    let that = this
    console.log(event.detail.value);
    that.setData({
      CjstateIndex:event.detail.index,
      CjstateValue: event.detail.value.id == 0 ? '' : event.detail.value.text,
      ispopupShow: false
    })
  },
  //运行
  onConfirmYxState(event) {
    let that = this
    console.log(event.detail.value);
    that.setData({
      YxstateIndex:event.detail.index,
      YxstateValue: event.detail.value.id == 0 ? '' : event.detail.value.text,
      ispopupShow: false
    })
  },
  //调试
  onConfirmTsState(event) {
    let that = this
    console.log(event.detail.value);
    that.setData({
      TsstateIndex:event.detail.index,
      TsstateValue: event.detail.value.id == 0 ? '' : event.detail.value.text,
      ispopupShow: false
    })
  },
  onClickInput(e) {
    let that = this
    that.setData({
      sign: e.currentTarget.dataset.sign,
      ispopupShow: true
    })
  },
  cancelpicker(e) {
    let that = this
    that.setData({
      ispopupShow: false
    })
    setTimeout(()=>{
      that.setData({
        sign:null
      })
    },200)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(JSON.parse(options.customCalloutobj));
    let that = this
    that.setData({
      customCalloutobj: JSON.parse(options.customCalloutobj)
    })
  },
  Querystation() {
    let that = this
    let queryParams = {}
    queryParams.CjstateValue = that.data.CjstateValue
    queryParams.CodingValue = that.data.CodingValue
    queryParams.FirmValue = that.data.FirmValue
    queryParams.YxstateValue = that.data.YxstateValue
    queryParams.TsstateValue = that.data.TsstateValue
    console.log('搜索电站',queryParams);
  },
  someStation() {
    let that = this
    console.log('更多信息stationquery');
    wx.navigateTo({
      url: '/pages/stationdetails/stationdetails?customCalloutobj=' + JSON.stringify(that.data.customCalloutobj),
    })
  },
  Openstation() {
    let that = this
    Dialog.confirm({
        title: '提示',
        message: '确定开启' + that.data.customCalloutobj.title + '？',
        confirmButtonText: '开 启',
        cancelButtonText: '取 消'
      })
      .then(() => {
        Toast.success('开启成功');
      })
      .catch(() => {
        // on cancel
      });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})